﻿using System;
using System.Collections.Generic;
using System.Text;
using Hkwl.WorldExpo.Merchant.Model;
using System.Collections;

namespace Hkwl.WorldExpo.Merchant.DataAccess.Impl.IBatisNet
{
    public class AdminSqlMapDao : BaseSqlMapDao, IAdminDao
    {
        #region NxAdmin 对象

        public NxAdmin GetNxAdminById(int adminId)
        {
            return ExecuteQueryForObject<NxAdmin>("SelectNxAdmin", adminId);
        }

        public bool InsertNxAdmin(NxAdmin admin)
        {
            object obj = ExecuteInsert("InsertNxAdmin", admin);
            if ((int)obj > 0)
            {
                return true;
            }
            else
            {
                return false;
            }

        }

        public bool UpdateNxAdmin(NxAdmin admin)
        {
            int ret = ExecuteUpdate("UpdateNxAdmin", admin);
            if (ret > 0)
            {
                return true;
            }
            else
            {
                return false;
            }
        }

        #endregion

        #region NxAdminPermission 对象

        public IList<NxAdminPermission> GetNxAdminPermissioinCollection()
        {
            return ExecuteQueryForList<NxAdminPermission>("SelectNxAdminPermission", null);
        }

        public bool InsertNxAdminPermission(NxAdminPermission permission)
        {
            object obj = ExecuteInsert("InsertNxAdminPermission", permission);
            if ((int)obj > 0)
            {
                return true;
            }
            else
            {
                return false;
            }
        }

        public bool UpdateNxAdminPermission(NxAdminPermission permission)
        {
            int ret = ExecuteUpdate("UpdateNxAdminPermission", permission);
            if (ret > 0)
            {
                return true;
            }
            else
            {
                return false;
            }
        }

        #endregion

        #region NxAdminLog 对象

        public bool InsertNxAdminLog(NxAdminLog adminLog)
        {
            object obj = ExecuteInsert("InsertNxAdmin", adminLog);
            if ((int)obj > 0)
            {
                return true;
            }
            else
            {
                return false;
            }
        }

        public NxAdminLog GetNxAdminLogById(int logId)
        {
            return ExecuteQueryForObject<NxAdminLog>("SelectNxAdminLog", logId);
        }

        public IList<NxAdminLog> GetNxAdminLogCollection(int adminId, int pageIndex, int pageSize, ref int count)
        {
            Hashtable ht = new Hashtable();
            ht["AdminId"] = adminId;

            count = ExecuteQueryForObject<int>("GetAdminLogCount", ht);
            return ExecuteQueryForList<NxAdminLog>("SelectNxAdminLog", ht, (pageIndex - 1) * pageSize, pageSize);
        }

        #endregion
    }
}
